﻿using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TXTD.Admin.Data.Entitys.System;
using TXTD.Admin.Framework.ExpressionCore;
using TXTD.Admin.Interface.System;
using TXTD.Admin.Model.Paging;

namespace TXTD.Admin.Service.System
{
    public class SysDictionaryService : BaseService<SysDictionary>, ISysDictionaryService
    {
        public SysDictionaryService(DbContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
        {
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <returns></returns>
        public PageResult<SysDictionary> GetPageList(SysDictionary model)
        {
            #region 动态凭借查询条件
            ExpressionHelper<SysDictionary> expressionHelper = new ExpressionHelper<SysDictionary>();
            expressionHelper.Contains(nameof(SysDictionary.DictCode), model.DictCode);
            expressionHelper.Contains(nameof(SysDictionary.DictName), model.DictName);
            var where = expressionHelper.GetExpression();
            #endregion
            return QueryPageList<SysDictionary>(where);
        }
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Add(SysDictionary model)
        {
            return InsertModel(model);
        }
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Update(SysDictionary model)
        {
            return UpdateModel(model, model.DictionaryId);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>

        public int DeleteById(string id)
        {
            return RemoveById(id);
        }
    }
}